package com.sigmatrix.h5.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.sigmatrix.h5.auth.AuthorizeInterceptor;
import com.sigmatrix.h5.auth.TestUtilInterceptor;
import com.sigmatrix.h5.web.dealer.DealerInterceptor;
import com.sigmatrix.h5.web.ins.InsInterceptor;
@Configuration
public class InterceporRegister extends WebMvcConfigurerAdapter{
	
	@Autowired
	private InsInterceptor insInterceptor;
	
	@Autowired
	private DealerInterceptor dealerInterceptor;
	
	@Autowired
	private AuthorizeInterceptor authorizeInterceptor;
	
	@Autowired
	private TestUtilInterceptor testUtilInterceptor;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
		registry.addInterceptor(testUtilInterceptor).addPathPatterns("/util/test/**");
		
		registry.addInterceptor(authorizeInterceptor).addPathPatterns("/shop/**","/ins/**","/rebate/**","/open/rebate/**","/dealer/**","/api/dealer/**","/open/dealer/**","/front/**");
		
		registry.addInterceptor(insInterceptor).addPathPatterns("/shop/**","/ins/**","/rebate/**","/open/rebate/**","/front/rebate/v2/**");
		registry.addInterceptor(dealerInterceptor).addPathPatterns("/dealer/**","/api/dealer/**","/open/dealer/**");
		super.addInterceptors(registry);
	}
	
}
